package com.google.project.client.Operator;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.project.client.Sharing.CreateMessage;
import com.google.project.client.Sharing.DailyReportDetail;
import com.google.project.client.Sharing.DocumentList;
import com.google.project.client.Sharing.MessageDetail;
import com.google.project.client.Sharing.MessageList;
import com.google.project.client.Sharing.ProjectTaskStaff;
import com.google.project.shared.DailyReportDTO;
import com.google.project.shared.MessageDTO;
import com.google.project.shared.ProjectDTO;
import com.google.project.shared.ProjectTaskDTO;

public class OPTEntrypoint implements EntryPoint {

	interface ConnectrAppUiBinder extends
			UiBinder<DockLayoutPanel, OPTEntrypoint> {
	}

	private static final ConnectrAppUiBinder binder = GWT
			.create(ConnectrAppUiBinder.class);
	private static OPTEntrypoint singleton;

	// @formatter:off
	@UiField
	HeaderPanel headerPanel;
	@UiField
	ScrollPanel mainPanel;

	// @formatter:on

	RootLayoutPanel root;

	/** Gets the singleton application instance. */
	public static OPTEntrypoint get() {
		return singleton;
	}

	@Override
	public void onModuleLoad() {
		singleton = this;
		DockLayoutPanel outer = binder.createAndBindUi(this);
		root = RootLayoutPanel.get();
		root.add(outer);
		mainPanel.add(new OPTHomePage());
	}

	public void cancelEditFriend() {
		clearMainPanel();
	}

	public void clearMainPanel() {
		mainPanel.clear();
	}

	public void OPTHomePage() {
		clearMainPanel();
		mainPanel.add(new OPTHomePage());

	}

	public void OPTProjectDetail(String projectId,int index) {
		clearMainPanel();
		mainPanel.add(new OPTProjectDetail(projectId,index));
	}

	public void OPTDailyReportList() {
		clearMainPanel();
		mainPanel.add(new OPTDailyReportList());
	}

	public void OPTCreateDailyReport() {
		clearMainPanel();
		mainPanel.add(new OPTCreateDailyReport());
	}

	public void OPTDailyReportDetail(DailyReportDTO dailyReportDTO) {
		clearMainPanel();
		mainPanel.add(new DailyReportDetail(dailyReportDTO));
	}

	public void OPTCreateDailyReport(String userID, String currentProjID) {
		clearMainPanel();
		mainPanel.add(new OPTCreateDailyReport(userID, currentProjID));

	}

	public void OPTCreateMessage() {
		clearMainPanel();
		mainPanel.add(new CreateMessage());
	}

	public void OPTMessageList() {
		clearMainPanel();
		mainPanel.add(new MessageList());
	}

	public void OPTMessageDetail(MessageDTO mess) {
		clearMainPanel();
		mainPanel.add(new MessageDetail(mess));
	}

	public void OPTTaskDetail(ProjectTaskDTO task) {
		clearMainPanel();
		mainPanel.add(new OPTProjectTaskDetail(task));
	}

	public void OPTTaskConstrain(ProjectTaskDTO currTask, String projectID,
			int i) {
		clearMainPanel();
		mainPanel.add(new OPTTaskConstrain(currTask, projectID, i));
	}

	public void DocumentList(String id, String i, String projectName,
			String taskName, int role) {
		clearMainPanel();
		mainPanel.add(new DocumentList(id, i, projectName, taskName, role));

	}

	public void OPTProjectTaskStaff(ProjectTaskDTO task, ProjectDTO project) {
		clearMainPanel();
		mainPanel.add(new ProjectTaskStaff(task, project));

	}

}
